function Controller(){
    if (installer.isUninstaller()){
        //installer.finishedCalculateComponentsToUninstall.connect(this, this.uninstallationStarted);
        installer.performOperation("Execute", ["@TargetDir@/minIO/storage_stop.bat"]);
        installer.uninstallationStarted.connect(this, this.uninstallationStarted);
        //installer.execute("mkdir", "hellohello2")
    }else{
        installer.installationFinished.connect(this, this.installationFinished);
        //installer.execute("mkdir", ["hellohello"])
    }    
}

var valid = true
Controller.prototype.IntroductionPageCallback = function()
{
    if (!installer.isUninstaller()){
        var widget = gui.currentPageWidget(); // get the current wizard page
        if (widget != null) {
            var hkeys = installer.execute("reg", ["QUERY", "HKEY_USERS"])[0].split("\n")
            var tmp = ""
            for (var i in hkeys){
                if (hkeys[i].indexOf("S-1-5-21") >= 0){
                    tmp = hkeys[i]
                    break
                }
            }
            hkeys = installer.execute("reg", ["QUERY", tmp.trim() + "\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall", "/s", "/v", "DisplayName"])[0].split("\n")
            for (var i in hkeys){
                if (hkeys[i].indexOf("DisplayName") >= 0 && hkeys[i].indexOf("DeepInspection") >= 0){
                    widget.title = "error!"
                    widget.MessageLabel.setText("DeepInspection is Installed, please uninstall at first")
                    valid = false
                    break
                }
            }
        }
    }
}

Controller.prototype.TargetDirectoryPageCallback = function()
{
    if (!installer.isUninstaller() && !valid){
        gui.clickButton(buttons.BuckButton)
    }
}

Controller.prototype.uninstallationStarted = function()
{
    //if (installer.fileExists("@TargetDir@/minIO/storage_uninstall.bat"))
        installer.performOperation("Execute", ["@TargetDir@/minIO/storage_uninstall.bat"]);
}

Controller.prototype.installationFinished = function()
{
    if (installer.fileExists("@TargetDir@/key.bat"))
        installer.performOperation("Execute", ["@TargetDir@/key.bat"]);
    //if (installer.fileExists("@TargetDir@/minIO/minIO_netsh.bat"))
        installer.performOperation("Execute", ["@TargetDir@/minIO/minIO_netsh.bat"]);
}